#pragma once
#include <unordered_map>
#include "../vfs/ILocation.h"
#include "../vfs/IDirectoryFwd.h"
#include "FileDescriptorLibrary.h"
#include "Hash.h"

namespace ja2{ namespace vfs
{
	//! Base class for all uncompressed libraries.
	class UncompressedLibraryLocation : public ILocation
	{
		// Typedefs
	protected:
		typedef std::unordered_map<boost::filesystem::path, DirectoryPtr_t, hash_path> DirCatalog_t;

		// Nested classes
	private:
		class IteratorImpl;

		// Attributes
	private:
		//! Library path.
		boost::filesystem::path const m_Path;
		//! Mount point.
		boost::filesystem::path m_MountPoint;
		//! Map of all directories.
		DirCatalog_t m_DirectoryMap;

		// Operations
	public:
		//! See base.
		virtual bool dir_exist(boost::filesystem::path const &FileName) const;
		//! See base.
		virtual DirectoryPtr_t get_dir(boost::filesystem::path const &Path) const;
		//! See base.
		virtual boost::filesystem::path const &get_path() const;
		//! See base.
		virtual PathVector_t get_sub_dirs() const;
		//! See base.
		virtual Iterator begin();
		//! See base.
		virtual Iterator end();
	protected:
		
		//! Add new directory.
		void add_directory(boost::filesystem::path const &Path, DirectoryPtr_t &pDir);
		//! Add new library file.
		void add_file(FileDescriptorLibrary const &File);
		//! Set mount point.
		void set_mount_point(boost::filesystem::path const &Path);
		//! Get mount point.
		boost::filesystem::path const &get_mount_point() const;

		// Construction/Destruction
	public:
		UncompressedLibraryLocation(boost::filesystem::path const &LibraryFilePath, boost::filesystem::path const &MountPoint);
		virtual ~UncompressedLibraryLocation() = 0 {}
	};
} /*vfs*/} /*ja2*/
